package com.itheima.controller;

import com.itheima.entity.Result;
import com.itheima.pojo.Menu;
import com.itheima.pojo.Permission;
import com.itheima.service.MenuService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/menu")
@CrossOrigin
public class MenuController {
    @Reference
    private MenuService menuService;

    //查询所有的菜单
    @RequestMapping("/findAllMenu")
    public Result findAllMenu(){
        List<Menu> list= menuService.findAllMenu();
        return new Result(true,"查询所有的菜单成功",list);
    }
    //添加一级菜单
@RequestMapping("/addOneMenu")
    public Result addOneMenu(@RequestBody Menu menu){
        menuService.addOneMenu(menu);
        return new Result(true,"添加一级菜单成功");
}
//添加二级菜单
@RequestMapping("/addTwoMenu")
public Result addTwoMenu(@RequestBody Menu menu){
    menuService.addTwoMenu(menu);
    return new Result(true,"添加一级菜单成功");
}

//修改菜单
@RequestMapping("/EditMenu")
public Result EditMenu(@RequestBody Menu menu){
    menuService.EditMenu(menu);
    return new Result(true,"添加一级菜单成功");
}
//删除菜单

    @RequestMapping("/deleteMenuById/{id}")
    public Result deleteMenuById(@PathVariable("id") Integer id ){
        menuService.deleteMenuById(id);
        return new Result(true,"删除菜单成功");
    }
}
